<?php
$name      = ($access && ($name = $access->getName("name"))) ? $name : $params["name"];
$parent_id = ($access && ($parent_id = $access->getField("parent_id"))) ? $parent_id : $params["parent_id"];
$type_id   = ($access && ($type_id = $access->getField("type_id"))) ? $type_id : $params["type_id"];
$link      = ($access && ($link = $access->getField("link"))) ? $link : $params["link"];
?>
<?php $this->render("Admin.Header");?>
<div id="wrapper">
	<div id="leftcol">
    <?php $this->render("Admin.Menu");?>
	</div>
	<div id="rightcol">
		<div id="main">
            <?php $this->render("Admin.Location");?>
			<div>
                <span><?php echo $error_message?></span>
            </div>
			<div class="container-block">
				<form method="POST">
					<table>
					<tbody>
						<tr>
							<td><label class="text-tip">请输入名称：</label></td>
							<td><input type="text" class="text" name="name" value="<?php echo $name?>" /></td>
							<td><span class="error-tip"></span></td>
						</tr>
						<tr>
							<td><label class="text-tip">请输入链接地址：</label></td>
							<td><input type="text" class="text" name="link" value="<?php echo $link?>" /></td>
							<td><span class="error-tip"></span></td>
						</tr>
						<tr>
							<td><label>请选择父节点</label></td>
							<td>
                                <select name="parent_id" id="parent_id">
                                    <option value="0">根节点</option>
                                <?php
                                foreach ($menu as $k => $v)
                                {
                                ?>
                                    <option value="<?php echo $v["id"]?>"><?php echo $v["name"]?></option>
                                    <?php
                                    if (isset($v["child"]) && $v["child"])
                                    {
                                        foreach ($v["child"] as $child)
                                        {
                                    ?>
                                        <option
                                        value="<?php echo $child["id"]?>"><?php echo "--".$child["name"]?></option>
                                    <?php
                                        }
                                    }
                                }
                                ?>
                                </select>
                            </td>
							<td><span class="error-tip"></span></td>
						</tr>
						<tr>
							<td><label>请选择类型</label></td>
							<td>
                                <select name="type_id" id="type_id">
                                <?php
                                foreach ($types as $k => $v)
                                {
                                ?>
                                    <option value="<?php echo $k?>"><?php echo $v?></option>
                                <?php
                                }
                                ?>
                                </select>
                            </td>
							<td><span class="error-tip"></span></td>
						</tr>
                        <tr><td colspan="2"><input type="submit" value="submit" /></td></tr>
					</tbody>
					</table>
                    <input type="hidden" name="act" value="act" />
				</form>
			</div>
	    </div>
	</div>
</div>
<?php $this->render("Admin.Footer");?>
<script type="text/javascript" src="<?php echo NICED_URL::getJsBaseURL()."/thirdparty/jquery/jquery-1.7.1.js"?>"></script>
<script>
(function($){
$(document).ready(function(){
    //set default value for form
    var params = <?php echo json_encode($params)?>;
    $("#type_id").val(params["type_id"]);
    $("#parent_id").val(params["parent_id"]);
});
})(jQuery)
</script>
